﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace EdexApiClient
{
    public partial class EdexApiContext
    {
        /// <summary>
        /// Получить перечень компаний
        /// </summary>
        /// <param name="search"></param>
        /// <returns></returns>
        public IEnumerable<SEC_COMPANIES_ACCESS> GetCompanyAccess()
        {
            var uri = String.Format("SEC_COMPANIES_ACCESS/?api_key={0}", this.session.APIKEY);
            return this.GetData<List<SEC_COMPANIES_ACCESS>>(uri);
        }

        public SEC_COMPANIES_ACCESS GetCompanyAccessDetails(Guid id)
        {
            var uri = String.Format("SEC_COMPANIES_ACCESS/{0}/?api_key={1}", id.ToString(), this.session.APIKEY);
            return this.GetData<SEC_COMPANIES_ACCESS>(uri);
        }

        public void AddCompanyAccess(SEC_COMPANIES_ACCESS data)
        {
            var uri = String.Format("SEC_COMPANIES_ACCESS/?api_key={0}", this.session.APIKEY);
            this.Post<SEC_COMPANIES_ACCESS>(uri, data);
        }

        public void UpdateCompanyAccess(SEC_COMPANIES_ACCESS data)
        {
            var uri = String.Format("SEC_COMPANIES_ACCESS/?api_key={0}", this.session.APIKEY);
            this.Put<SEC_COMPANIES_ACCESS>(uri, data);
        }

        public void DeleteCompanyAccess(string id)
        {
            var uri = String.Format("SEC_COMPANIES_ACCESS/{0}/?api_key={1}", id, this.session.APIKEY);
            this.Delete(uri);
        }
    }
}